package servlet;

import dao.StudentDao;
import dao.UsersDao;
import vo.Student;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by ssw on 2018/6/18.
 */
public class AddStudentServlet extends HttpServlet{
    @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        req.setCharacterEncoding("utf-8");
        String sid=req.getParameter("sid");
        String sname=new String(req.getParameter("sname").getBytes("ISO-8859-1"),"UTF-8");
//        String sname=req.getParameter("sname");
        String clname=req.getParameter("clname");
        String upass="aaa";
        UsersDao usersDao=new UsersDao ();
        boolean res=usersDao.addUser(sid,upass,sname,clname);
        if(res)
            req.getRequestDispatcher("sgms/admin_adduser.jsp?res=1").forward(req, resp);
        else
            req.getRequestDispatcher("sgms/admin_adduser.jsp?res=0").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
